#include"ownh.h"
#include"ArmorDetector.h"
#include"poseSolver.h"
#include"Predictor.h"
#include"serialport.h"
#include"ImageConsProd.h"
#include<thread>
#define EXPOSURE -1
#define USEPORT
using namespace std;
using namespace cv;
void cameraInit(VideoCapture& cap){
   
    cap.set(CAP_PROP_AUTO_EXPOSURE, 0.25); // where 0.25 means "manual exposure, manual iris"
    cap.set(CAP_PROP_EXPOSURE, EXPOSURE);
    return ;
}

void autoshoot(){
     // communicate with car
    SerialPort port;
#ifdef USEPORT
    port.open_port();
    port.initSerialPort();
#endif
    // start threads
    ImageConsProd image_cons_prod(port);    
    // 利用多线程加快速度
    std::thread t1(&ImageConsProd::ImageProducer, std::ref(image_cons_prod)); // pass by reference
    std::thread t2(&ImageConsProd::ImageConsumer, std::ref(image_cons_prod));

    t1.join();
    t2.join();
    port.closePort();
    return ;
}